package com.wly.jmockito.service.impl;

import com.wly.jmockito.service.UserService;

/**
 * Description: 每个方法执行都要统计执行时间
 * Copyright: Copyright (c) 2024
 * Create Time: 2024-11-08 16:55
 *
 * @author wanglianyun
 */
public class UserServiceImpl implements UserService {
    @Override
    public void login(String name, String pwd) throws Exception {
        // 利用代理记录方法耗时
//        long start = System.currentTimeMillis();
        // 具体业务
        if ("admin".equals(name) && "123456".equals(pwd)) {
            System.out.println("登录成功");
        } else {
            System.out.println("登录失败");
        }
        Thread.sleep(1000);
//        long end = System.currentTimeMillis();
//        System.out.println("用户登录方法执行时间为：" + (end - start) / 1000 + "s");
    }

    @Override
    public void deleteUsers() throws Exception {
        // 利用代理记录耗时
//        long start = System.currentTimeMillis();
        // 具体业务
        System.out.println("删除用户成功");
        Thread.sleep(1000);
//        long end = System.currentTimeMillis();
//        System.out.println("删除用户方法执行时间为：" + (end - start) / 1000 + "s");
    }
}
